<?php
// 加购商品
// header("content-type:text/html;charset=utf-8");
include_once("conn.php");

//时区设置为中国
date_default_timezone_set('PRC');

//获取当前时间
$now = date('Y-m-d H:i:s');

$cid = "GY" . date('YmdHis') . mt_rand(1000, 9999);
//获取前端GET方法传来的JSON数据
$json = file_get_contents('php://input');
//将JSON数据转换为PHP数组
$data = json_decode($_GET['i'], true);

$uid = $data['uid'];
$goods_id = $data['goods_id'];
$address = $data['address'];
$name = $data['name'];
$phone = $data['phone'];
$num = $data['num'];

//将数据插入到数据库中

$sql_insert = "INSERT INTO tb_cart_info SET c_id = '".$cid."',uid = '".$uid."',g_id = '".$goods_id."',c_address = '".$address."',c_name = '".$name."',c_phone = '".$phone."',c_num = '".$num."',c_date = '".$now."'";
$result = mysqli_query($conn, $sql_insert);
if ($result) {
    echo "1";
}else{
    echo "0";
}